package com.atguigu3.common_algorithm.exer2;

/**
 * ClassName: ArrayExer2
 * Package: com.atguigu3.common_algorithm.exer2
 * Description:
 * 在编程竞赛中，有10为评委为参赛的选手打分，分数分别为：5,4,6,8,9,0,1,2,7,3
 * 求选手的最后得分（去掉一个最高分和一个最低分后其余8位评委打分的平均值）
 *
 * @Author 姜
 * @Create 2023/11/14 17:05
 * @Version 1.0
 */
public class ArrayExer2 {
    public static void main(String[] args) {
        int[] scores = {5, 4, 6, 8, 9, 0, 1, 2, 7, 3};
        int sum = 0;
        int max = scores[0];
        int min = scores[0];
        for (int i = 0; i < scores.length; i++) {
            if (scores[i] > max) {
                max = scores[i];
            }
            if (scores[i] < min) {
                min = scores[i];
            }
            sum += scores[i];
        }
        System.out.println("平均值为: " + (sum - max - min) / scores.length);
    }
}
